const iot = require('alibabacloud-iot-device-sdk');


module.exports = function getData(data) {
  result = parseFloat(data.value);
  console.log(result);


  const device = iot.device({
    productKey: 'gr8maSvPyaF', //将${productKey}修改为实际产品的ProductKey
    deviceName: 'temperature1',//将${deviceName}修改为实际设备的DeviceName
    deviceSecret: 'c1c069292ab9ed2838f069b8a45e2543',//将${deviceSecret}修改为实际设备的DeviceSecret
  });
  


  device.on('connect', () => {

    console.log('connect successfully!');
  
    // device.publish('/gr8maSvPyaF/temperature1/user/update', '2222');

   //上报设备属性
      device.postProps({
        CurrentTemperature: result
      }, (res) => {
        console.log(res);
      });
  });
}















